import {createRouter,createWebHashHistory} from 'vue-router'
import routerPages from './router'
const routes = [...routerPages]
const router = createRouter({
    history: createWebHashHistory(),
    routes 
   
})

router.beforeEach((to, from, next) => {
    console.log(localStorage.getItem('userToken'));
    // 判断有没有登录
    if (!localStorage.getItem('userToken')) {
        if (to.name == "login") {
            next();
        } else {
            router.push('login')
        }
    } else {
        next();
    }
});
export default router
